package testrj.tools;

import testrj.domain.DomainObject;
import testrj.domain.TestrjConfig;
import testrj.util.ReflectionUtils;

public class DataStubGenerator {
	public void generateStubFor(Object object) {
		DomainObject domainObject = DomainObject.asDomainObject(object);
		TestrjConfig.persister.persistData(domainObject);
	}

	@SuppressWarnings("unchecked")
	public void generateStubFor(Class clazz) {
		generateStubFor(ReflectionUtils.getInstanceOfClassForcibly(clazz));
	}

	public void generateStubFor(String className) {
		generateStubFor(ReflectionUtils.getClassForClassName(className));
	}

	public static DataStubGenerator newInstance() {
		return new DataStubGenerator();
	}

	private DataStubGenerator() {
	}

	public static void main(String[] args) {
		DataStubGenerator.newInstance().generateStubFor("testrj.domain.MethodToTest");
		DataStubGenerator.newInstance().generateStubFor("testrj.domain.DomainObject");
		DataStubGenerator.newInstance().generateStubFor("testrj.domain.SerializedData");
		DataStubGenerator.newInstance().generateStubFor("testrj.domain.TestCase");
	}
}